<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class News extends Home_Controller {
    
    public function __construct() {
        parent::__construct();
		$this->load->model('News_model');
      
        
    }
	
	public function index(){
		$data = array();
		$data['top_menu'] = "news";
		$data['left_menu'] = "news";
		$data['count'] = $this->News_model->count(array("cid"=>2,'status'=>1));
		$data['title'] = "公司新闻";
		$page_obj = $this->pager(base_url("news.html"),$data['count'],10);
		$data['list'] = $this->News_model->search(array("cid"=>2,'status'=>1),"",10,$page_obj['start_page']);
		$data['page_html'] = $page_obj['pager_html'];
		$this->layout_view('home/news/news_lists',$data);
		
		/*$where =array("cid"=>2,'status'=>1);
		$id = (int)$this->input->get_post('id');
		if($id){
			$where['id'] = $id;
		}
		$new_info = $this->News_model->read($where,"id DESC");
		if($new_info){
			$data['new_info'] = $new_info;
			$data['new_info']['content'] = help_zsh_content_full_img($new_info['content']);
			
			$data['pre_news'] = $this->News_model->read(array("cid"=>2,'status'=>1,'id <'=>$new_info['id']),"id DESC");
			$data['next_news'] = $this->News_model->read(array("cid"=>2,'status'=>1,'id >'=>$new_info['id']),"id DESC");

			
			$this->layout_view('home/news/news_index',$data);
		}else{
			$this->layout_view('home/news/news_index_defalut',$data);
		}*/
	}
  
	public function movement(){
		$data = array();
		$data['top_menu'] = "news";
		$data['left_menu'] = "movement";
		$data['count'] = $this->News_model->count(array("cid"=>3,'status'=>1));
		$data['title'] = "企业动态";
		$page_obj = $this->pager(base_url("news/movement.html"),$data['count'],10);
		$data['list'] = $this->News_model->search(array("cid"=>3,'status'=>1),"",10,$page_obj['start_page']);
		$data['page_html'] = $page_obj['pager_html'];
		$this->layout_view('home/news/news_lists',$data);
	}
	
	public function show($id){
		$data = array();
		$data['top_menu'] = "news";
		$data['left_menu'] = "news";
		$where['id'] = $id;
		$new_info = $this->News_model->read($where,"id DESC");
		
		$data['new_info'] = $new_info;
		$data['new_info']['content'] = help_zsh_content_full_img($new_info['content']);
		$data['pre_news'] = $this->News_model->read(array("cid"=>$new_info['cid'],'status'=>1,'id <'=>$new_info['id']),"id DESC");
		$data['next_news'] = $this->News_model->read(array("cid"=>$new_info['cid'],'status'=>1,'id >'=>$new_info['id']),"id DESC");
		if($new_info['cid'] == 3){
			$data['left_menu'] = "movement";
			
		}
		
		$this->layout_view('home/news/news_movement',$data);
		
	}
    
	public function  weixin_meishi(){
		$where =array("cid"=>5,'status'=>1);
		$new_list = $this->News_model->search($where,"","","","id DESC");
		$data['list'] = $new_list;
		$this->weixin_layout_view('home/weixin/news_list',$data);
	}
	
	public function weixin_news(){
		$where =array("cid"=>6,'status'=>1);
		$new_list = $this->News_model->search($where,"","","","id DESC");
		$data['list'] = $new_list;
		$this->weixin_layout_view('home/weixin/news_list',$data);
	}
}
